#ifndef THUMBNAILBARWIDGET_H
#define THUMBNAILBARWIDGET_H

#include <QWidget>
#include <QBoxLayout>
class ImageInstance;
class SeriesInstance;
class DicomImageLabel;
class ImageLoadThread;
class DcmFileFormat;

class ThumbnailBarWidget : public QWidget
{
    Q_OBJECT

public:
    explicit ThumbnailBarWidget(QWidget *parent = 0);
    ~ThumbnailBarWidget();

    void setDirection(QBoxLayout::Direction direction) { layout->setDirection(direction); }
    DicomImageLabel *getCurrentImageLabel() const { return currentImageLabel; }

    QList<SeriesInstance*> getSeriesList() const;
    int getNumberOfLabels() const { return imageLabelList.size(); }
    QSize sizeHint() const;

signals:
    void currentChanged(SeriesInstance *series);
    void imageDoubleClicked(SeriesInstance *series);
    void seriesInserted(SeriesInstance *series);
    void quitFileWatcher();

public slots:
    void setCurrentImageLabel(const SeriesInstance *series);
    void appendImagePaths(const QStringList &paths, bool clearOld = false);
    void appendFileFormat(DcmFileFormat *dcmff);
    void setImagePaths(const QStringList &paths) { appendImagePaths(paths, true); }
    void clear();
    void updateLabelImage(const SeriesInstance *series);
    void setFileWatcher(const QString &dir);

    void firstSeries();
    void lastSeries();
    void nextSeries();
    void prevSeries();
    void currSeries();

protected slots:
    void onImageReady(ImageInstance *image);
    void onImageClicked(DicomImageLabel *imageLabel);
    void onImageDoubleClicked(DicomImageLabel *imageLabel);
    void onFilesChanged(const QStringList &removed, const QStringList &added);

private:
    QBoxLayout *layout;
    QList<DicomImageLabel*> imageLabelList;
    DicomImageLabel *currentImageLabel;
};

#endif // THUMBNAILBARWIDGET_H
